<#include '/share.include'>

package ${basepackage}.service.impl;

import ${basepackage}.db.domain.PageInfo;
import ${basepackage}.db.domain.PageControl;
import ${basepackage}.bean.admin.${className};
import ${basepackage}.service.${className}Service;
import ${basepackage}.dao.${className}Dao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
		import java.util.List;
/**
 * ${table.remarks}
 * @author ${author}
 * @date ${.now?datetime}
 */
@Service
public class ${className}ServiceImpl implements ${className}Service {

    @Autowired
    private ${className}Dao ${classNameLow}Dao;
	/**
	 * 根据实体${className}，新增${table.remarks} 信息
	 * 返回影响行数
	 */
    public Integer insert${className}(${className} ${classNameLow}){
    	//判断传入的${className}是否为空
		if (${classNameLow} == null) {
			return 0;
		}
		//执行新增操作，具体请看 ${className}Mapper.xml
		Integer i = ${classNameLow}Dao.insert(${classNameLow});
		return i;
    }
	/**
	 * 根据实体${className}，更新${table.remarks} 信息，用主键更新
	 * 返回影响行数
	 */
    public Integer update${className}(${className} ${classNameLow}){
		//判断传入的${className}是否为空
		if (${classNameLow} == null) {
			return 0;
		}
		//执行更新操作，具体请看 ${className}Mapper.xml
		Integer i = ${classNameLow}Dao.update(${classNameLow});
		return i;
    }
	/**
	 * 分页查询
	 */
    public PageControl<${className}> page(${className} ${classNameLow}, PageInfo pageInfo, String whereSql, String orderSql){
		return ${classNameLow}Dao.getPageByObj(${classNameLow}, pageInfo, whereSql, orderSql);
    }
	/**
	 * 根据主键id，查询一个实体${className}
	 * 返回实体${className}
	 */
    public ${className} find(Integer id){
		return ${classNameLow}Dao.getEntityById(id);
    }
	/**
	 * 根据主键id，逻辑删除数据
	 * 返回影响行数
	 */
    public Integer delete(Integer id){
		${className} temp = new ${className}();
		//设置主键id
		temp.setId(id);
		//设置删除标志,其实是设置了${className}的有效标志
		temp.setDeleted(true);
		//执行更新操作，具体请看 ${className}Mapper.xml
		return ${classNameLow}Dao.update(temp);
    }


<#list columns as column>
<#if column.columnNameFirstLower='youxbz'>
/**
 * 作废恢复，有作废标志对有用
 */
public Integer zouf(Integer id,${column.possibleShortJavaType} bz){
		${className} temp = new ${className}();
		//设置主键id
		temp.setId(id);
		if (bz>0){
		bz = 0;
		}else{
		bz = 1;
		}
		//置了${className}的有效标志
		temp.setYouxbz(bz);
		//执行更新操作，具体请看 ${className}Mapper.xml
		return ${classNameLow}Dao.update(temp);
		}

/**
 * 获取所有有效的类型
 * @return
 */
@Override
public List<${className}> getAllByYouxbz() {
		${className} entity = new ${className}();
		return ${classNameLow}Dao.getListByObj(entity," youxbz = 1 ");
		}


</#if>
</#list>

}
